﻿#include <iostream>
#include <ctime>
#include "HuffmanTree.h"
using namespace std;

int* initialRandomArray(int n)
{
	int a;
	int* array = new int[n];
	for (int i = 0; i < n; i++)
	{
		a = rand() % 100;
		array[i] = a;
	}
	return array;
}

void displayArray(int* array, int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << array[i] << " ";
	}
	cout << endl;
}

int main()
{
	int number = 10;

	srand((int)time(0));
	int* a1 = initialRandomArray(number);
	int* a2 = initialRandomArray(number);
	cout << "两个数组的初始化情况：" << endl;
	displayArray(a1, number);
	displayArray(a2, number);

	HuffmanTree h1 = HuffmanTree(a1, number);
	HuffmanTree h2 = HuffmanTree(a2, number);

	h1.displayTree();
	cout << endl;
	h2.displayTree();
	cout << endl;

	h1.breadthSearch();
	h2.breadthSearch();
}
